#include "../include/head.h"

void list_find(LinkList L)
{
    goodsNode goods = read_data(L);
    list_printf(L);
}
void list_set(LinkList L)
{
    goodsNode goods = userInput();
    list_head_insert(L, goods);
    write_data(L);
}
void list_del(LinkList L)
{
    printf("请输入要购买的商品名称 数量\n");
    char name[20];
    int num;
    scanf("%s %d", name, &num);
    read_data(L);
    list_reduce_num(L, name, num);
    LinkList goodsNode = list_find_by_name(L, name);
    write_data(L);
    show_one_goods(goodsNode->data);
}
void main(int argc, char const *argv[])
{
    home_hint();
    int type = -1;
    LinkList L = createList();
    scanf("%d", &type);
    switch (type)
    {
    case 1:
        printf("您选择了录入商品功能\n");
        list_set(L);
        break;
    case 2:
        printf("您选择了查看商品列表功能\n");
        list_find(L);
        break;
    case 3:
        printf("您选择了选购商品功能\n");
        list_del(L);
        break;
    case 4:
        printf("您选择了选购商品功能\n");
        list_del(L);
        break;
    default:
        break;
    }
}
